package com.goldenautumn.prefabricate.activity.mine.address

import android.os.Handler
import android.os.Looper
import com.github.gzuliyujiang.wheelpicker.contract.AddressLoader
import com.github.gzuliyujiang.wheelpicker.contract.AddressParser
import com.github.gzuliyujiang.wheelpicker.contract.AddressReceiver
import com.github.gzuliyujiang.wheelpicker.entity.ProvinceEntity
import java.util.concurrent.Executors


class TextAddressLoader(private val data:List<ProvinceEntity>?) : AddressLoader {
    override fun loadJson(receiver: AddressReceiver, parser: AddressParser) {
        Executors.newSingleThreadExecutor().execute(Runnable {
            try {
                Handler(Looper.getMainLooper()).post(Runnable { data?.let {
                    receiver.onAddressReceived(
                        it
                    )
                } })
            } catch (ignore: Exception) {
            }
        })
    }
}